import java.awt.Point;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.util.Properties;
import java.util.logging.Logger;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.methods.Calculations;
import org.rsbot.script.methods.Game;
import org.rsbot.script.methods.GroundItems;
import org.rsbot.script.methods.Interfaces;
import org.rsbot.script.methods.Keyboard;
import org.rsbot.script.methods.Mouse;
import org.rsbot.script.methods.NPCs;
import org.rsbot.script.methods.Players;
import org.rsbot.script.methods.Walking;
import org.rsbot.script.wrappers.RSComponent;
import org.rsbot.script.wrappers.RSGroundItem;
import org.rsbot.script.wrappers.RSInterface;
import org.rsbot.script.wrappers.RSNPC;
import org.rsbot.script.wrappers.RSPlayer;
import org.rsbot.util.GlobalConfiguration.Paths;

class WhiteBearAIOMagic$Antiban
{
  int moveMouseB = 75; int allRand = 21; int cam = 27; int skill = 45; int player = 18; int friend = 61;

  boolean checkFriend = false; boolean checkExperience = true; boolean screenLookaway = false;

  long timeOutA1 = 600000L; long timeOutA2 = 800000L; long lengthA1 = 1000L; long lengthA2 = 3000L;

  long timeFriend = System.currentTimeMillis(); long timeExp = System.currentTimeMillis();

  long timeLook = System.currentTimeMillis();
  long timeOutFriend = 20000L; long timeOutExp = 20000L;

  private WhiteBearAIOMagic$Antiban(WhiteBearAIOMagic paramWhiteBearAIOMagic) {  }

  private void main(boolean paramBoolean) { WhiteBearAIOMagic.access$5100(this.this$0).setSpeed(this.this$0.random(WhiteBearAIOMagic.access$4900(this.this$0) + 1, WhiteBearAIOMagic.access$5000(this.this$0) + 1));
    if (!this.this$0.chatRes.typing) {
      if ((WhiteBearAIOMagic.access$5200(this.this$0) < System.currentTimeMillis()) && (WhiteBearAIOMagic.access$5300(this.this$0).getEnergy() >= this.this$0.random(79, 90)))
      {
        WhiteBearAIOMagic.access$5202(this.this$0, System.currentTimeMillis() + 7000L);
        WhiteBearAIOMagic.access$5400(this.this$0).setRun(true);
        this.this$0.sleep(100);
      }
      int i = this.this$0.random(1, this.allRand);
      if ((i == 1) && 
        (this.this$0.random(1, 3) == 1)) {
        this.this$0.chatRes.wait = true;
        WhiteBearAIOMagic.access$5700(this.this$0).move(this.this$0.random(5, WhiteBearAIOMagic.access$5500(this.this$0).getWidth()), this.this$0.random(5, WhiteBearAIOMagic.access$5600(this.this$0).getHeight()));

        this.this$0.chatRes.wait = false;
      }

      if (i == 2) {
        int j = this.this$0.random(1, this.cam);
        if (j <= 4) {
          WhiteBearAIOMagic.access$3512(this.this$0, 1);
          this.this$0.chatRes.wait = true;
          turnCamera();
          this.this$0.chatRes.wait = false;
        }
      }
      if ((this.checkExperience) && (i == 6) && 
        (System.currentTimeMillis() > this.timeExp) && (this.this$0.random(1, this.skill) == 1) && (this.this$0.getMyPlayer().getAnimation() != -1))
      {
        if (WhiteBearAIOMagic.access$5800(this.this$0).getCurrentTab() != 1) {
          this.this$0.chatRes.wait = true;
          WhiteBearAIOMagic.access$5900(this.this$0).openTab(1);
          Point localPoint = new Point(WhiteBearAIOMagic.access$6000(this.this$0).get(320).getComponent(87).getAbsoluteX() + 20, WhiteBearAIOMagic.access$6100(this.this$0).get(320).getComponent(87).getAbsoluteY() + 10);

          WhiteBearAIOMagic.access$6200(this.this$0).move(localPoint, 5, 5);
          sleepCR(this.this$0.random(28, 31));
          this.timeExp = (System.currentTimeMillis() + ()this.this$0.random(this.timeOutExp - 1500L, this.timeOutExp + 1500L));

          this.this$0.chatRes.wait = false;
        }
      }

      if ((i == 7) && 
        (this.this$0.random(0, 2) == 0) && 
        (this.checkFriend) && (System.currentTimeMillis() > this.timeFriend) && (this.this$0.random(1, this.friend) == 1))
      {
        if ((this.this$0.getMyPlayer().getAnimation() != -1) || ((this.this$0.getMyPlayer().isMoving()) && (WhiteBearAIOMagic.access$6400(this.this$0).distanceTo(WhiteBearAIOMagic.access$6300(this.this$0).getDestination()) > 5)))
        {
          this.this$0.chatRes.wait = true;
          WhiteBearAIOMagic.access$6500(this.this$0).openTab(9);
          sleepCR(this.this$0.random(18, 25));
          this.timeFriend = (System.currentTimeMillis() + ()this.this$0.random(this.timeOutFriend - 1500L, this.timeOutFriend + 1500L));

          this.this$0.chatRes.wait = false;
        }

      }

      if ((i == 8) && 
        (paramBoolean == true)) {
        int k = this.this$0.random(1, this.player);
        if (k == 1) {
          RSPlayer localRSPlayer = WhiteBearAIOMagic.access$6600(this.this$0).getNearest(Players.ALL_FILTER);

          if ((localRSPlayer != null) && (WhiteBearAIOMagic.access$6700(this.this$0).distanceTo(localRSPlayer) != 0)) {
            this.this$0.chatRes.wait = true;
            WhiteBearAIOMagic.access$6800(this.this$0).move(localRSPlayer.getScreenLocation(), 5, 5);
            sleepCR(this.this$0.random(6, 9));
            WhiteBearAIOMagic.access$6900(this.this$0).click(false);
            sleepCR(this.this$0.random(15, 17));
            WhiteBearAIOMagic.access$7000(this.this$0).move(this.this$0.random(10, 450), this.this$0.random(10, 495));
            this.this$0.chatRes.wait = false;
          }
        }
      }
    }

    WhiteBearAIOMagic.access$7100(this.this$0).setSpeed(this.this$0.random(WhiteBearAIOMagic.access$4900(this.this$0), WhiteBearAIOMagic.access$5000(this.this$0))); }

  private void turnCamera()
  {
    if ((WhiteBearAIOMagic.access$2100(this.this$0) == 2) || (WhiteBearAIOMagic.access$2100(this.this$0) == 3) || (WhiteBearAIOMagic.access$2100(this.this$0) == 7))
      return;
    char[] arrayOfChar1 = { '%', '\'' };
    char[] arrayOfChar2 = { '(', '&' };
    char[] arrayOfChar3 = { '%', '\'', '&', '&' };

    int i = this.this$0.random(0, 2);
    int j = this.this$0.random(0, 2);
    int k = this.this$0.random(0, 4);

    if (this.this$0.random(0, 3) == 0) {
      WhiteBearAIOMagic.access$7200(this.this$0).pressKey(arrayOfChar1[i]);
      sleepCR(this.this$0.random(2, 9));
      WhiteBearAIOMagic.access$7300(this.this$0).pressKey(arrayOfChar2[j]);
      sleepCR(this.this$0.random(6, 10));
      WhiteBearAIOMagic.access$7400(this.this$0).releaseKey(arrayOfChar2[j]);
      sleepCR(this.this$0.random(2, 7));
      WhiteBearAIOMagic.access$7500(this.this$0).releaseKey(arrayOfChar1[i]);
    } else {
      WhiteBearAIOMagic.access$7600(this.this$0).pressKey(arrayOfChar3[k]);
      if (k > 1)
        sleepCR(this.this$0.random(6, 11));
      else {
        sleepCR(this.this$0.random(9, 12));
      }
      WhiteBearAIOMagic.access$7700(this.this$0).releaseKey(arrayOfChar3[k]);
    }
  }

  private boolean lookAway() {
    if ((!this.this$0.chatRes.typing) && (this.screenLookaway) && (this.timeLook < System.currentTimeMillis()) && (this.this$0.random(0, 111) == 0))
    {
      this.this$0.chatRes.pause = true;
      WhiteBearAIOMagic.access$1702(this.this$0, "Antiban");
      if (this.this$0.random(0, this.moveMouseB) <= 50) {
        WhiteBearAIOMagic.access$7800(this.this$0).setSpeed(this.this$0.random(3, 5));
        WhiteBearAIOMagic.access$8100(this.this$0).move(this.this$0.random(40, WhiteBearAIOMagic.access$7900(this.this$0).getWidth() - 50), WhiteBearAIOMagic.access$8000(this.this$0).getHeight());

        WhiteBearAIOMagic.access$8200(this.this$0).setSpeed(this.this$0.random(WhiteBearAIOMagic.access$4900(this.this$0), WhiteBearAIOMagic.access$5000(this.this$0)));
      }
      int i = this.this$0.random(0, 101);
      if (!WhiteBearAIOMagic.access$2000(this.this$0))
        i = 1;
      int j = 0;
      int k = 0;
      int m = (int)(this.lengthA1 / 100L); int n = (int)(this.lengthA2 / 100L);
      while ((WhiteBearAIOMagic.access$8300(this.this$0)) && (k < this.this$0.random(m, n))) {
        k++;
        this.this$0.sleep(100);
      }
      if (i > 57) {
        j = this.this$0.random(50, 200);
        this.this$0.sleep(j);
      }
      WhiteBearAIOMagic.access$8400(this.this$0).info("[Antiban] Simulated looking away from screen, waited an extra " + j + " ms.");

      this.timeLook = ()(System.currentTimeMillis() + this.this$0.random(this.timeOutA1, this.timeOutA2));

      this.this$0.chatRes.pause = false;
      return true;
    }
    return false;
  }

  private boolean telekineticLA() {
    if ((!this.this$0.chatRes.typing) && (this.screenLookaway) && (this.timeLook < System.currentTimeMillis()) && (this.this$0.random(0, 111) == 0))
    {
      this.this$0.chatRes.pause = true;
      WhiteBearAIOMagic.access$1702(this.this$0, "Look Away");
      if (this.this$0.random(0, this.moveMouseB) <= 50) {
        WhiteBearAIOMagic.access$8500(this.this$0).setSpeed(this.this$0.random(3, 5));
        WhiteBearAIOMagic.access$8800(this.this$0).move(this.this$0.random(40, WhiteBearAIOMagic.access$8600(this.this$0).getWidth() - 50), WhiteBearAIOMagic.access$8700(this.this$0).getHeight());

        WhiteBearAIOMagic.access$8900(this.this$0).setSpeed(this.this$0.random(WhiteBearAIOMagic.access$4900(this.this$0), WhiteBearAIOMagic.access$5000(this.this$0)));
      }
      int i = this.this$0.random(0, 101);
      if (!WhiteBearAIOMagic.access$2000(this.this$0))
        i = 1;
      int j = 0;
      int k = 0;
      int m = this.this$0.random(750, 830);
      while ((WhiteBearAIOMagic.access$8300(this.this$0)) && (k < m)) {
        RSGroundItem localRSGroundItem = WhiteBearAIOMagic.access$9100(this.this$0).getNearest(new int[] { WhiteBearAIOMagic.access$9000(this.this$0) });
        if ((localRSGroundItem != null) && (WhiteBearAIOMagic.access$9200(this.this$0).tileOnScreen(localRSGroundItem.getLocation()))) {
          break;
        }
        k++;
        this.this$0.sleep(100);
      }
      if (i > 57) {
        j = this.this$0.random(500, 3500);
        this.this$0.sleep(j);
      }
      WhiteBearAIOMagic.access$9300(this.this$0).info("[Antiban] Simulated looking away from screen, waited an extra " + j + " ms.");

      this.timeLook = ()(System.currentTimeMillis() + this.this$0.random(this.timeOutA1, this.timeOutA2));

      this.this$0.chatRes.pause = false;
      return true;
    }
    return false;
  }

  private boolean curseLA() {
    if ((!this.this$0.chatRes.typing) && (this.screenLookaway) && (this.timeLook < System.currentTimeMillis()) && (this.this$0.random(0, 111) == 0))
    {
      this.this$0.chatRes.pause = true;
      WhiteBearAIOMagic.access$1702(this.this$0, "Look Away");
      if (this.this$0.random(0, this.moveMouseB) <= 50) {
        WhiteBearAIOMagic.access$9400(this.this$0).setSpeed(this.this$0.random(3, 5));
        WhiteBearAIOMagic.access$9700(this.this$0).move(this.this$0.random(40, WhiteBearAIOMagic.access$9500(this.this$0).getWidth() - 50), WhiteBearAIOMagic.access$9600(this.this$0).getHeight());

        WhiteBearAIOMagic.access$9800(this.this$0).setSpeed(this.this$0.random(WhiteBearAIOMagic.access$4900(this.this$0), WhiteBearAIOMagic.access$5000(this.this$0)));
      }
      int i = this.this$0.random(0, 101);
      if (!WhiteBearAIOMagic.access$2000(this.this$0))
        i = 1;
      int j = 0;
      int k = 0;
      int m = this.this$0.random(750, 830);
      while ((WhiteBearAIOMagic.access$8300(this.this$0)) && (k < m)) {
        RSNPC localRSNPC = WhiteBearAIOMagic.access$10000(this.this$0).getNearest(new int[] { WhiteBearAIOMagic.access$9900(this.this$0) });
        if ((localRSNPC != null) && (WhiteBearAIOMagic.access$10100(this.this$0).tileOnScreen(localRSNPC.getLocation()))) {
          break;
        }
        k++;
        this.this$0.sleep(100);
      }
      if (i > 57) {
        j = this.this$0.random(500, 3500);
        this.this$0.sleep(j);
      }
      WhiteBearAIOMagic.access$10200(this.this$0).info("[Antiban] Simulated looking away from screen, waited an extra " + j + " ms.");

      this.timeLook = ()(System.currentTimeMillis() + this.this$0.random(this.timeOutA1, this.timeOutA2));

      this.this$0.chatRes.pause = false;
      return true;
    }
    return false;
  }

  private RSPlayer getNearbyMod()
  {
    RSPlayer[] arrayOfRSPlayer = WhiteBearAIOMagic.access$10300(this.this$0).getAll();
    int i = 18;
    RSPlayer localRSPlayer = null;
    int j = 0;
    int k = arrayOfRSPlayer.length;
    while (j < k) {
      if (arrayOfRSPlayer[j] != null)
        try {
          if (arrayOfRSPlayer[j].getName().startsWith("Mod")) {
            int m = WhiteBearAIOMagic.access$10400(this.this$0).distanceTo(arrayOfRSPlayer[j]);
            if (m < i) {
              i = m;
              localRSPlayer = arrayOfRSPlayer[j];
            }
          }
        }
        catch (Exception localException) {
        }
      j++;
    }
    return localRSPlayer;
  }

  private void breakingNew() {
    if (WhiteBearAIOMagic.access$2800(this.this$0)) {
      long l1 = this.this$0.random(7200000, 18000000);
      WhiteBearAIOMagic.access$3302(this.this$0, System.currentTimeMillis() + l1);
      long l3 = this.this$0.random(120000, 600000);
      WhiteBearAIOMagic.access$3402(this.this$0, l3);
    } else {
      int i = WhiteBearAIOMagic.access$3000(this.this$0) * 1000 * 60;
      long l2 = this.this$0.random(WhiteBearAIOMagic.access$2900(this.this$0) * 1000 * 60 - i, WhiteBearAIOMagic.access$2900(this.this$0) * 1000 * 60 + i);

      WhiteBearAIOMagic.access$3302(this.this$0, System.currentTimeMillis() + l2);
      int j = WhiteBearAIOMagic.access$3200(this.this$0) * 1000 * 60;
      long l4 = this.this$0.random(WhiteBearAIOMagic.access$3100(this.this$0) * 1000 * 60 - j, WhiteBearAIOMagic.access$3100(this.this$0) * 1000 * 60 + j);

      WhiteBearAIOMagic.access$3402(this.this$0, l4);
    }
  }

  private boolean breakingCheck()
  {
    return WhiteBearAIOMagic.access$3300(this.this$0) <= System.currentTimeMillis();
  }

  private boolean personalize()
  {
    try
    {
      WhiteBearAIOMagic.access$10500(this.this$0).load(new FileInputStream(new File(GlobalConfiguration.Paths.getSettingsDirectory(), "WhiteBearAIOMagicV2.ini")));
    }
    catch (Exception localException1)
    {
    }
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABallRand") == null)
      WhiteBearAIOMagic.access$10500(this.this$0).setProperty("ABallRand", Integer.toString(this.this$0.random(20, 23)));
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABcam") == null)
      WhiteBearAIOMagic.access$10500(this.this$0).setProperty("ABcam", Integer.toString(this.this$0.random(26, 29)));
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABskill") == null)
      WhiteBearAIOMagic.access$10500(this.this$0).setProperty("ABskill", Integer.toString(this.this$0.random(44, 49)));
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABplayer") == null)
      WhiteBearAIOMagic.access$10500(this.this$0).setProperty("ABplayer", Integer.toString(this.this$0.random(19, 23)));
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABfriend") == null) {
      WhiteBearAIOMagic.access$10500(this.this$0).setProperty("ABfriend", Integer.toString(this.this$0.random(59, 69)));
    }
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABtimeOutFriend") == null) {
      WhiteBearAIOMagic.access$10500(this.this$0).setProperty("ABtimeOutFriend", Integer.toString(this.this$0.random(33000, 60000)));
    }
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABtimeOutExp") == null) {
      WhiteBearAIOMagic.access$10500(this.this$0).setProperty("ABtimeOutExp", Integer.toString(this.this$0.random(25000, 50000)));
    }

    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABmoveMouseB") == null)
      WhiteBearAIOMagic.access$10500(this.this$0).setProperty("ABmoveMouseB", Integer.toString(this.this$0.random(55, 105)));
    try
    {
      WhiteBearAIOMagic.access$10500(this.this$0).store(new FileWriter(new File(GlobalConfiguration.Paths.getSettingsDirectory(), "WhiteBearAIOMagicV2.ini")), "The GUI Settings for White Bear AIO Magic (Version: " + Double.toString(this.this$0.properties.version()) + ")");
    }
    catch (Exception localException2)
    {
      WhiteBearAIOMagic.access$10600(this.this$0).severe("[ERROR] Could not save settings file!");
      return false;
    }
    boolean bool = this.this$0.antiban.load();
    while (!bool) {
      bool = this.this$0.antiban.load();
    }
    return true;
  }

  private boolean load() {
    try {
      WhiteBearAIOMagic.access$10500(this.this$0).load(new FileInputStream(new File(GlobalConfiguration.Paths.getSettingsDirectory(), "WhiteBearAIOMagicV2.ini")));
    }
    catch (Exception localException)
    {
      WhiteBearAIOMagic.access$10700(this.this$0).severe("[ERROR] Could not load settings file!");
      return false;
    }
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABallRand") != null)
      this.allRand = Integer.parseInt(WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABallRand"));
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABcam") != null)
      this.cam = Integer.parseInt(WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABcam"));
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABskill") != null)
      this.skill = Integer.parseInt(WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABskill"));
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABplayer") != null)
      this.player = Integer.parseInt(WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABplayer"));
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABfriend") != null) {
      this.friend = Integer.parseInt(WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABfriend"));
    }
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABtimeOutFriend") != null) {
      this.timeOutFriend = Integer.parseInt(WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABtimeOutFriend"));
    }
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABtimeOutExp") != null) {
      this.timeOutExp = Integer.parseInt(WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABtimeOutExp"));
    }
    if (WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABmoveMouseB") != null) {
      this.moveMouseB = Integer.parseInt(WhiteBearAIOMagic.access$10500(this.this$0).getProperty("ABmoveMouseB"));
    }
    return true;
  }

  private boolean sleepCR(int paramInt) {
    for (int i = 0; i < paramInt + 1; i++) {
      this.this$0.sleep(this.this$0.random(48, 53));
      if (this.this$0.chatRes.typing) {
        return false;
      }
    }
    return true;
  }
}